# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=qt5-qtx11extras
pkgver=5.15.10_git20230424
pkgrel=1
_module="${pkgname#qt5-}"
_pkgver=74f81f0bfe17e5aabcebafcb0cf36f739133554c
_fullname=$_module-$_pkgver
pkgdesc="Provides platform-specific APIs for X11"
url="https://www.qt.io/developers/"
arch="all"
license="( LGPL-3.0-or-later OR GPL-3.0-only OR GPL-2.0-or-later ) AND Qt-GPL-exception-1.0"
makedepends="qt5-qtbase-dev"
subpackages="$pkgname-dev"
replaces="qt5-x11extras"
source="https://dev.alpinelinux.org/archive/qt/$_fullname.tar.xz"
builddir="$srcdir/$_fullname"

_disturl="dev.alpinelinux.org:/archive/qt/"
snapshot() {
	clean
	makedepends="git xz rsync tar" deps
	mkdir -p "$srcdir" && cd "$srcdir"
	git clone --filter=tree:0 https://invent.kde.org/qt/qt/$_module.git .
	git archive --format tar --prefix=$_fullname/ $_pkgver > "$SRCDEST"/$_fullname.tar
	xz -vv -T0 -9 -e "$SRCDEST"/$_fullname.tar
	rsync --progress -La "$SRCDEST"/$_fullname.tar.xz $_disturl
}

prepare() {
	default_prepare

	# We need to make the build system think we're running in a git repository
	# so it correctly symlinks during the build
	mkdir .git
}

build() {
	qmake-qt5
	make
}

check() {
	make check
}

package() {
	make INSTALL_ROOT="$pkgdir" install

	# Drop QMAKE_PRL_BUILD_DIR because reference the build dir
	find "$pkgdir/usr/lib" -type f -name '*.prl' \
		-exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;
}

sha512sums="
f366054ee76ae022c0dd3f85761facacdff012a7608c0be1e7f2f80ba660a56bf8880d6a77e8e3475ef59207f1057c8943cdc9471aacdaa418de38c22c5b9ee5  qtx11extras-74f81f0bfe17e5aabcebafcb0cf36f739133554c.tar.xz
"
